<template>
  <view class="container">
    <view class="section">
      <text class="section-title">阿里云OSS存储设置</text>
      <view class="form-row">
        <label>Access Key ID:</label>
        <input v-model="settings.accessKeyId" class="input-field" />
      </view>
      <view class="form-row">
        <label>Access Key Secret:</label>
        <input v-model="settings.accessKeySecret" class="input-field" />
      </view>
      <view class="form-row">
        <label>Bucket Name:</label>
        <input v-model="settings.bucketName" class="input-field" />
      </view>
      <view class="form-row">
        <label>Endpoint:</label>
        <input v-model="settings.endpoint" class="input-field" />
      </view>
      <view class="form-row">
        <label>Region:</label>
        <input v-model="settings.region" class="input-field" />
      </view>
    </view>

    <view class="button-group">
      <uni-button type="primary" @click="saveSettings">保存</uni-button>
      <uni-button type="default" @click="resetSettings">重置</uni-button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      settings: {
        accessKeyId: '',
        accessKeySecret: '',
        bucketName: '',
        endpoint: '',
        region: ''
      }
    };
  },
  methods: {
    saveSettings() {
      // 将 settings 保存到服务器或本地存储
      console.log('保存设置', this.settings);
      uni.showToast({
        title: '设置已保存',
        icon: 'success'
      });
    },
    resetSettings() {
      // 重置 settings 为默认值
      this.settings = {
        accessKeyId: '',
        accessKeySecret: '',
        bucketName: '',
        endpoint: '',
        region: ''
      };
      uni.showToast({
        title: '设置已重置',
        icon: 'none'
      });
    }
  }
};
</script>

<style scoped>
.container {
  padding: 10px;
  background-color: #f5f5f5;
}
.section {
  margin-bottom: 20px;
  background-color: #fff;
  padding: 15px;
  border-radius: 5px;
  border: 1px solid #e0e0e0;
}
.section-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 10px;
}
.form-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
label {
  width: 120px;
  font-weight: bold;
}
.input-field {
  flex: 1;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  outline: none;
}
.button-group {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}
</style>
